﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CommandServer;

namespace BTClient
{
    public partial class Client : Form
    {
        BTClient btClient;

        public Client()
        {
            InitializeComponent();
            btClient = new BTClient();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (btClient.connect())
            {
                labelConnect.Text = "connected";
            }
            else 
            {
                labelConnect.Text = "ooops";
            }
            
        }

        private void consoleText(String s)
        {
            textConsole.Text = s + Environment.NewLine;
        }

        private void buttonLine_Click(object sender, EventArgs e)
        {
            btClient.sendXML(new BTXMLDriveCom(Command.LINE, Double.Parse(textSpeed.Text), Double.Parse(textAcceleration.Text), Double.Parse(textLength.Text), Double.Parse(textRadius.Text),Double.Parse(textAngle.Text)));
            consoleText(btClient.ResponseText);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            btClient.sendXML(new BTXMLDriveCom(Command.LEFT, Double.Parse(textSpeed.Text), Double.Parse(textAcceleration.Text), Double.Parse(textLength.Text), Double.Parse(textRadius.Text), Double.Parse(textAngle.Text)));
            consoleText(btClient.ResponseText);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            btClient.sendXML(new BTXMLDriveCom(Command.RIGHT, Double.Parse(textSpeed.Text), Double.Parse(textAcceleration.Text), Double.Parse(textLength.Text), Double.Parse(textRadius.Text), Double.Parse(textAngle.Text)));
            consoleText(btClient.ResponseText);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            btClient.sendXML(new BTXMLDriveCom(Command.TURN, Double.Parse(textSpeed.Text), Double.Parse(textAcceleration.Text), Double.Parse(textLength.Text), Double.Parse(textRadius.Text), Double.Parse(textAngle.Text)));
            consoleText(btClient.ResponseText);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            btClient.sendXML(new BTXMLDriveCom(Command.GO, Double.Parse(textSpeed.Text), Double.Parse(textAcceleration.Text), Double.Parse(textLength.Text), Double.Parse(textRadius.Text), Double.Parse(textAngle.Text)));
            consoleText(btClient.ResponseText);
        }

            
    }
}
